#!/bin/bash

# Author: Turing Zhu<qishiwenjun@163.com>
# Date: 2018-06-13 18:51:37
# Desc: restart jar
#

# error code
# 1: missing jarfile

function print_help() {
    cat <<EOF
restart the specified jar process
Usage:      $0 jarfile
Example:    $0 abc.jar

EOF
}

function main() {
    # check parameter
    if [[ $# -lt 1 ]];then
		printf "[ \033[31mERROR 1\033[0m ] missing parameter\n"
        print_help
        exit 1
    fi
	CURDIR=$(dirname $(which $0))
	${CURDIR}/stop.sh $1
	${CURDIR}/start.sh $1
	printf "\033[32m RESTART $pid of $jarfile SUCCESS. \033[0m\n"
}


main $*
